package com.seeyon.apps.schedule.dao.impl;

import com.seeyon.apps.schedule.dao.ScheduleDao;
import com.seeyon.apps.schedule.util.ScheduleUtil;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.util.FlipInfo;
import com.seeyon.ctp.util.JDBCAgent;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Title:ScheduleDaoImImpl
 * Description: 盐城市政府项目-日程相关接口实现类
 * @author wxt.chenfan
 * @version 2024-11-28
 * @Date 2024-11-28
 */
public class ScheduleDaoImImpl implements ScheduleDao {
    @Override
    public List<Map<String, Object>> getLeaveNum(String sql) {
        JDBCAgent jdbcAgent = new JDBCAgent(true);
        try {
            List<Map<String, Object>> namedSql = jdbcAgent.findNamedSql(sql, new HashMap<>());
            return namedSql;
        } catch (BusinessException e) {
            ScheduleUtil.chenfan("获取请假人数失败","ScheduleDaoImImpl.getLeaveNum",e);
        } finally {
            if (jdbcAgent != null) {
                jdbcAgent.close();
            }
        }
        return null;
    }

    @Override
    public FlipInfo getLeavedetails(FlipInfo flipInfo, String sql) {
        JDBCAgent jdbcAgent = new JDBCAgent(true);
        try {
            flipInfo = jdbcAgent.findNameByPaging(sql, new HashMap<>(),flipInfo);
            return flipInfo;
        } catch (Exception e) {
            ScheduleUtil.chenfan("获取请假明细列表败","ScheduleDaoImImpl.getLeavedetails",e);
        } finally {
            if (jdbcAgent != null) {
                jdbcAgent.close();
            }
        }
        return null;
    }
}
